package com.maimao.model.goods.input;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.maimao.model.goods.SpecDetails;
import lombok.*;

import java.util.List;

/**
 * 规格表单
 * @author MaoLin Wang
 * @date 2020/12/13 9:47 上午
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class SpecDetailForm  extends SpecDetails {

    /**
     * 如果是数字类型且可搜索 则需要填写搜搜项
     */
    private List<String> searchOptions;

    /**
     * 如果是SELECT 或 MULTI_SELECT 则需要填写规格下拉选项
     */
    private List<String> specOptions;

    @Override
    public String toString() {
        return "SpecDetailForm{" +
                "searchOptions=" + searchOptions +
                ", specOptions=" + specOptions +
                '}';
    }

    public SpecDetails toSpecDetails(){
        return SpecDetails.builder().id(getId())
                .categoryId(getCategoryId())
                .common(getCommon())
                .formType(getFormType())
                .groupId(getGroupId())
                .name(getName())
                .numberic(getNumberic())
                .order(getOrder())
                .searchable(getSearchable())
                .searchOptional(getSearchOptional())
                .unit(getUnit())
                .build();
    }
}
